package com.example.tests;

import org.junit.*;

//import java.util.Collections;
//import java.util.List;

import static org.junit.Assert.*;

import com.example.pages.UsersPage;

public class CreateNewUser extends TestBase {

	@Test
	public void createNewUser() {
		UsersPage userPage = goToMainPage()
		        .loginWithValidCredentials("admin", "admin")
				.gotoUserManagementConsole();
		
		SortedListOf<User> oldUserList = userPage.getUsers();
		
				
		User user = new User().withName("user1").withEmail("user1@test.com").withPassword("test");
		
		if (oldUserList.contains(user)){
			userPage.deleteUser(user);
			oldUserList = userPage.getUsers();
		}
		
	
		userPage.createUser(user);
		
	    SortedListOf<User> newUserList = userPage.getUsers();		
				
		
	    assertEquals(newUserList, oldUserList.withAdded(user));
	    
	    
	}

}
